<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>QxOrm: C:/Dvlp/_Perso/QxOrm/include/QxSerialize/boost/portable_binary/portable_iarchive.hpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo_qxorm.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">QxOrm
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
   <div id="projectbrief">C++ Object Relational Mapping library</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('portable__iarchive_8hpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">portable_iarchive.hpp</div>  </div>
</div>
<div class="contents">
<a href="portable__iarchive_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************/</span>
<a name="l00060"></a>00060 <span class="comment">/*****************************************************************************/</span>
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="preprocessor">#ifdef _QX_ENABLE_BOOST_SERIALIZATION</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span><span class="preprocessor">#if _QX_SERIALIZE_PORTABLE_BINARY</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span><span class="preprocessor">#ifndef _QX_PORTABLE_BINARY_IARCHIVE_H_</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span><span class="preprocessor">#define _QX_PORTABLE_BINARY_IARCHIVE_H_</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>
<a name="l00067"></a>00067 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#endif // _MSC_VER</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span>
<a name="l00071"></a>00071 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00072"></a>00072 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(push)</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(disable:4996)</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(disable:4661)</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor">#endif // _MSC_VER</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>
<a name="l00077"></a>00077 <span class="preprocessor">#include &lt;istream&gt;</span>
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 <span class="comment">// basic headers</span>
<a name="l00080"></a>00080 <span class="preprocessor">#include &lt;boost/version.hpp&gt;</span>
<a name="l00081"></a>00081 <span class="preprocessor">#include &lt;boost/utility/enable_if.hpp&gt;</span>
<a name="l00082"></a>00082 <span class="preprocessor">#include &lt;boost/archive/binary_iarchive.hpp&gt;</span>
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="comment">// endian and fpclassify</span>
<a name="l00085"></a>00085 <span class="preprocessor">#if BOOST_VERSION &lt; 103600</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/integer/endian.hpp&gt;</span>
<a name="l00087"></a>00087 <span class="preprocessor">#include &lt;boost/math/fpclassify.hpp&gt;</span>
<a name="l00088"></a>00088 <span class="preprocessor">#else</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/spirit/home/support/detail/integer/endian.hpp&gt;</span>
<a name="l00090"></a>00090 <span class="preprocessor">#include &lt;boost/spirit/home/support/detail/math/fpclassify.hpp&gt;</span>
<a name="l00091"></a>00091 <span class="preprocessor">#endif</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span>
<a name="l00093"></a>00093 <span class="comment">// namespace alias</span>
<a name="l00094"></a>00094 <span class="preprocessor">#if BOOST_VERSION &lt; 103800</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span><span class="keyword">namespace </span>fp = boost::math;
<a name="l00096"></a>00096 <span class="preprocessor">#else</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span><span class="keyword">namespace </span>fp = boost::spirit::math;
<a name="l00098"></a>00098 <span class="preprocessor">#endif</span>
<a name="l00099"></a>00099 <span class="preprocessor"></span>
<a name="l00100"></a>00100 <span class="comment">// generic type traits for numeric types</span>
<a name="l00101"></a>00101 <span class="preprocessor">#include &lt;boost/type_traits/is_integral.hpp&gt;</span>
<a name="l00102"></a>00102 <span class="preprocessor">#include &lt;boost/type_traits/is_unsigned.hpp&gt;</span>
<a name="l00103"></a>00103 <span class="preprocessor">#include &lt;boost/type_traits/is_arithmetic.hpp&gt;</span>
<a name="l00104"></a>00104 <span class="preprocessor">#include &lt;boost/type_traits/is_floating_point.hpp&gt;</span>
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <span class="preprocessor">#include &quot;<a class="code" href="portable__archive__exception_8hpp.html">portable_archive_exception.hpp</a>&quot;</span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="comment">// hint from Johan Rade: on VMS there is still support for</span>
<a name="l00109"></a>00109 <span class="comment">// the VAX floating point format and this macro detects it</span>
<a name="l00110"></a>00110 <span class="preprocessor">#if defined(__vms) &amp;&amp; defined(__DECCXX) &amp;&amp; !__IEEE_FLOAT</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="preprocessor">#error &quot;VAX floating point format is not supported!&quot;</span>
<a name="l00112"></a>00112 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span>
<a name="l00114"></a>00114 <span class="preprocessor">#if (BOOST_VERSION &gt;= 104400)</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span><span class="preprocessor">#define QX_ARCHIVE_PORTABLE_BINARY_VERSION_PATCH (boost::archive::library_version_type)(3)</span>
<a name="l00116"></a>00116 <span class="preprocessor"></span><span class="preprocessor">#elif (BOOST_VERSION &gt;= 104200)</span>
<a name="l00117"></a>00117 <span class="preprocessor"></span><span class="preprocessor">#define QX_ARCHIVE_PORTABLE_BINARY_VERSION_PATCH (boost::archive::version_type)(3)</span>
<a name="l00118"></a>00118 <span class="preprocessor"></span><span class="preprocessor">#else // (BOOST_VERSION &gt;= 104200)</span>
<a name="l00119"></a><a class="code" href="portable__iarchive_8hpp.html#a40af5ff99c97a853b2b159b5da225438">00119</a> <span class="preprocessor"></span><span class="preprocessor">#define QX_ARCHIVE_PORTABLE_BINARY_VERSION_PATCH 3</span>
<a name="l00120"></a>00120 <span class="preprocessor"></span><span class="preprocessor">#endif // (BOOST_VERSION &gt;= 104200)</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span>
<a name="l00122"></a>00122 <span class="keyword">namespace </span>eos {
<a name="l00123"></a>00123 
<a name="l00124"></a>00124    <span class="comment">// forward declaration</span>
<a name="l00125"></a><a class="code" href="namespaceeos.html#a30d84adedcc8dddf6b23d7921cb45b9c">00125</a>    <span class="keyword">class </span><a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">portable_iarchive</a>;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127    <span class="comment">// convenience archive base class typedef</span>
<a name="l00128"></a>00128    <span class="keyword">typedef</span> boost::archive::binary_iarchive_impl&lt;
<a name="l00129"></a>00129       <a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">portable_iarchive</a>
<a name="l00130"></a>00130 <span class="preprocessor">      #if BOOST_VERSION &gt;= 103400</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span>         , std::istream::char_type 
<a name="l00132"></a>00132          , std::istream::traits_type
<a name="l00133"></a>00133 <span class="preprocessor">      #endif</span>
<a name="l00134"></a>00134 <span class="preprocessor"></span>   &gt; <a class="code" href="namespaceeos.html#a30d84adedcc8dddf6b23d7921cb45b9c">portable_iarchive_base</a>;
<a name="l00135"></a>00135 
<a name="l00153"></a><a class="code" href="classeos_1_1portable__iarchive.html">00153</a>    <span class="keyword">class </span><a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">portable_iarchive</a> : <span class="keyword">public</span> <a class="code" href="namespaceeos.html#a30d84adedcc8dddf6b23d7921cb45b9c">portable_iarchive_base</a>
<a name="l00154"></a>00154 <span class="preprocessor">   #if BOOST_VERSION &gt;= 103500</span>
<a name="l00155"></a>00155 <span class="preprocessor"></span>      <span class="comment">// mix-in helper class for serializing shared_ptr</span>
<a name="l00156"></a>00156       , <span class="keyword">public</span> boost::archive::detail::shared_ptr_helper
<a name="l00157"></a>00157 <span class="preprocessor">   #endif</span>
<a name="l00158"></a>00158 <span class="preprocessor"></span>   {
<a name="l00159"></a>00159       <span class="comment">// workaround for gcc: use a dummy struct</span>
<a name="l00160"></a>00160       <span class="comment">// as additional argument type for overloading</span>
<a name="l00161"></a><a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html#a03ff7111fc968c39840ed603418bd7b7">00161</a>       <span class="keyword">template</span> &lt;<span class="keywordtype">int</span>&gt; <span class="keyword">struct </span><a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html">dummy</a> { <a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html#a03ff7111fc968c39840ed603418bd7b7">dummy</a>(<span class="keywordtype">int</span>) {}};
<a name="l00162"></a>00162 
<a name="l00163"></a>00163       <span class="comment">// loads directly from stream</span>
<a name="l00164"></a><a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">00164</a>       <span class="keywordtype">signed</span> <span class="keywordtype">char</span> <a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">load_signed_char</a>() 
<a name="l00165"></a>00165       { 
<a name="l00166"></a>00166          <span class="keywordtype">signed</span> <span class="keywordtype">char</span> c; 
<a name="l00167"></a>00167          <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">portable_iarchive_base::load</a>(c); 
<a name="l00168"></a>00168          <span class="keywordflow">return</span> c; 
<a name="l00169"></a>00169       }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171    <span class="keyword">public</span>:
<a name="l00172"></a>00172 
<a name="l00174"></a>00174       <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00175"></a>00175       <span class="keyword">typename</span> boost::disable_if&lt;boost::is_arithmetic&lt;T&gt; &gt;::type 
<a name="l00176"></a><a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131">00176</a>       <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">load</a>(T&amp; t, <a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html">dummy&lt;1&gt;</a> = 0)
<a name="l00177"></a>00177       {
<a name="l00178"></a>00178          <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">portable_iarchive_base::load</a>(t);
<a name="l00179"></a>00179       }
<a name="l00180"></a>00180 
<a name="l00184"></a><a class="code" href="classeos_1_1portable__iarchive.html#a4067389ec38e5b69c49dbd2314c07085">00184</a>       <span class="keywordtype">void</span> <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">load</a>(<span class="keywordtype">bool</span>&amp; b) 
<a name="l00185"></a>00185       { 
<a name="l00186"></a>00186          <span class="keywordflow">switch</span> (<span class="keywordtype">signed</span> <span class="keywordtype">char</span> c = <a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">load_signed_char</a>())
<a name="l00187"></a>00187          {
<a name="l00188"></a>00188             <span class="keywordflow">case</span> 0: b = <span class="keyword">false</span>; <span class="keywordflow">break</span>;
<a name="l00189"></a>00189             <span class="keywordflow">case</span> 1: b = <a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">load_signed_char</a>(); <span class="keywordflow">break</span>;
<a name="l00190"></a>00190             <span class="keywordflow">default</span>: <span class="keywordflow">throw</span> <a class="code" href="classeos_1_1portable__archive__exception.html" title="Exception being thrown when serialization cannot proceed.">portable_archive_exception</a>(c);
<a name="l00191"></a>00191          }
<a name="l00192"></a>00192       }
<a name="l00193"></a>00193 
<a name="l00201"></a>00201       <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00202"></a>00202       <span class="keyword">typename</span> boost::enable_if&lt;boost::is_integral&lt;T&gt; &gt;::type
<a name="l00203"></a><a class="code" href="classeos_1_1portable__iarchive.html#ae4a8d09c896094b29de77b1ea419d399">00203</a>       <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">load</a>(T &amp; t, <a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html">dummy&lt;2&gt;</a> = 0)
<a name="l00204"></a>00204       {
<a name="l00205"></a>00205          <span class="comment">// get the number of bytes in the stream</span>
<a name="l00206"></a>00206          <span class="keywordflow">if</span> (<span class="keywordtype">signed</span> <span class="keywordtype">char</span> size = <a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">load_signed_char</a>())
<a name="l00207"></a>00207          {
<a name="l00208"></a>00208             <span class="comment">// check for negative value in unsigned type</span>
<a name="l00209"></a>00209             <span class="keywordflow">if</span> (size &lt; 0 &amp;&amp; boost::is_unsigned&lt;T&gt;::value) <span class="keywordflow">throw</span> <a class="code" href="classeos_1_1portable__archive__exception.html" title="Exception being thrown when serialization cannot proceed.">portable_archive_exception</a>();
<a name="l00210"></a>00210 
<a name="l00211"></a>00211             <span class="comment">// check that our type T is large enough</span>
<a name="l00212"></a>00212             <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<span class="keywordtype">unsigned</span>) abs(size) &gt; <span class="keyword">sizeof</span>(T)) <span class="keywordflow">throw</span> <a class="code" href="classeos_1_1portable__archive__exception.html" title="Exception being thrown when serialization cannot proceed.">portable_archive_exception</a>(size);
<a name="l00213"></a>00213 
<a name="l00214"></a>00214             <span class="comment">// reconstruct the value</span>
<a name="l00215"></a>00215             T temp = size &lt; 0 ? -1 : 0;
<a name="l00216"></a>00216             load_binary(&amp;temp, abs(size));
<a name="l00217"></a>00217 
<a name="l00218"></a>00218             <span class="comment">// load the value from little endian - is is then converted</span>
<a name="l00219"></a>00219             <span class="comment">// to the target type T and fits it because size &lt;= sizeof(T)</span>
<a name="l00220"></a>00220             t = boost::detail::load_little_endian&lt;T, sizeof(T)&gt;(&amp;temp);
<a name="l00221"></a>00221          }
<a name="l00222"></a>00222          <span class="keywordflow">else</span> t = 0; <span class="comment">// zero optimization</span>
<a name="l00223"></a>00223       }
<a name="l00224"></a>00224 
<a name="l00252"></a>00252       <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00253"></a>00253       <span class="keyword">typename</span> boost::enable_if&lt;boost::is_floating_point&lt;T&gt; &gt;::type
<a name="l00254"></a><a class="code" href="classeos_1_1portable__iarchive.html#a2cc32b4f86f4fcba5c0481ada47f4505">00254</a>       <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">load</a>(T &amp; t, <a class="code" href="structeos_1_1portable__iarchive_1_1dummy.html">dummy&lt;3&gt;</a> = 0)
<a name="l00255"></a>00255       {
<a name="l00256"></a>00256          <span class="keyword">typedef</span> <span class="keyword">typename</span> fp::detail::fp_traits&lt;T&gt;::type traits;
<a name="l00257"></a>00257 
<a name="l00258"></a>00258          <span class="comment">// if you end here there are three possibilities:</span>
<a name="l00259"></a>00259          <span class="comment">// 1. you&#39;re serializing a long double which is not portable</span>
<a name="l00260"></a>00260          <span class="comment">// 2. you&#39;re serializing a double but have no 64 bit integer</span>
<a name="l00261"></a>00261          <span class="comment">// 3. your machine is using an unknown floating point format</span>
<a name="l00262"></a>00262          <span class="comment">// after reading the note above you still might decide to </span>
<a name="l00263"></a>00263          <span class="comment">// deactivate this static assert and try if it works out.</span>
<a name="l00264"></a>00264          <span class="keyword">typename</span> traits::bits bits;
<a name="l00265"></a>00265          BOOST_STATIC_ASSERT(<span class="keyword">sizeof</span>(bits) == <span class="keyword">sizeof</span>(T));
<a name="l00266"></a>00266          BOOST_STATIC_ASSERT(std::numeric_limits&lt;T&gt;::is_iec559);
<a name="l00267"></a>00267 
<a name="l00268"></a>00268          <a class="code" href="classeos_1_1portable__iarchive.html#a631092f514c8ab02978c0a01f95cb131" title="Default fall through for non-arithmetic types (ie. strings)">load</a>(bits);
<a name="l00269"></a>00269          traits::set_bits(t, bits);
<a name="l00270"></a>00270 
<a name="l00271"></a>00271          <span class="comment">// if you end here your floating point type does not support </span>
<a name="l00272"></a>00272          <span class="comment">// denormalized numbers. this might be the case even though </span>
<a name="l00273"></a>00273          <span class="comment">// your type conforms to IEC 559 (and thus to IEEE 754)</span>
<a name="l00274"></a>00274          <span class="keywordflow">if</span> (std::numeric_limits&lt;T&gt;::has_denorm == std::denorm_absent 
<a name="l00275"></a>00275          &amp;&amp; t &amp;&amp; !fp::isnormal(t)) <span class="keywordflow">throw</span> <a class="code" href="classeos_1_1portable__archive__exception.html" title="Exception being thrown when serialization cannot proceed.">portable_archive_exception</a>(t);
<a name="l00276"></a>00276       }
<a name="l00277"></a>00277 
<a name="l00279"></a><a class="code" href="classeos_1_1portable__iarchive.html#a61fe6428b7fa845c152bfd1c45c9665e">00279</a>       <a class="code" href="classeos_1_1portable__iarchive.html#a61fe6428b7fa845c152bfd1c45c9665e" title="always construct on a stream using ios::binary mode!">portable_iarchive</a>(std::istream&amp; is, <span class="keywordtype">unsigned</span> flags = 0)
<a name="l00280"></a>00280          <span class="comment">// the base class constructor calls basic_binary_iarchive::init</span>
<a name="l00281"></a>00281          <span class="comment">// but also basic_binary_iprimitive::init which loads type sizes</span>
<a name="l00282"></a>00282          <span class="comment">// and throws an exception when they are different - no way!</span>
<a name="l00283"></a>00283          : <a class="code" href="namespaceeos.html#a30d84adedcc8dddf6b23d7921cb45b9c">portable_iarchive_base</a>(is, flags | boost::archive::no_header) 
<a name="l00284"></a>00284       {
<a name="l00285"></a>00285          <span class="keyword">using namespace </span>boost::archive;
<a name="l00286"></a>00286 
<a name="l00287"></a>00287          <span class="comment">// it is vital to have version information!</span>
<a name="l00288"></a>00288          <span class="comment">// if we don&#39;t have any we assume boost 1.33</span>
<a name="l00289"></a>00289          <span class="keywordflow">if</span> (flags &amp; no_header) set_library_version(<a class="code" href="portable__iarchive_8hpp.html#a40af5ff99c97a853b2b159b5da225438">QX_ARCHIVE_PORTABLE_BINARY_VERSION_PATCH</a>);
<a name="l00290"></a>00290 
<a name="l00291"></a>00291          <span class="comment">// extract and check the magic eos byte</span>
<a name="l00292"></a>00292          <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classeos_1_1portable__iarchive.html#ad3ee71758c04224aeb8d174468b95ef4">load_signed_char</a>() != <a class="code" href="namespaceeos.html#a2b914ee3cd010de929b74c407657bc71">magic_byte</a>) <span class="keywordflow">throw</span> archive_exception(archive_exception::invalid_signature);
<a name="l00293"></a>00293 
<a name="l00294"></a>00294          <span class="keywordflow">else</span>
<a name="l00295"></a>00295          {
<a name="l00296"></a>00296             <span class="comment">// extract version information</span>
<a name="l00297"></a>00297             version_type input_library_version;
<a name="l00298"></a>00298             <a class="code" href="_qx_bool_8h.html#a01172f4bf3386f123bdcfd8b260f977a">operator&gt;&gt;</a>(input_library_version);
<a name="l00299"></a>00299 
<a name="l00300"></a>00300             <span class="comment">// throw if file version is newer than we are</span>
<a name="l00301"></a>00301             <span class="keywordflow">if</span> (input_library_version &gt; <a class="code" href="namespaceeos.html#a7d65f2fb4ec23237bebd297f68718086">archive_version</a>)
<a name="l00302"></a>00302             <span class="keywordflow">throw</span> archive_exception(archive_exception::unsupported_version);
<a name="l00303"></a>00303 
<a name="l00304"></a>00304             <span class="comment">// else set the library version accordingly</span>
<a name="l00305"></a>00305             <span class="keywordflow">else</span> set_library_version(input_library_version);
<a name="l00306"></a>00306          }
<a name="l00307"></a>00307       }
<a name="l00308"></a>00308    };
<a name="l00309"></a>00309 
<a name="l00310"></a>00310 } <span class="comment">// namespace eos</span>
<a name="l00311"></a>00311 
<a name="l00312"></a>00312 <span class="comment">// this is required by export which registers all of your</span>
<a name="l00313"></a>00313 <span class="comment">// classes with all the inbuilt archives plus our archive.</span>
<a name="l00314"></a>00314 <span class="preprocessor">#if BOOST_VERSION &lt; 103500</span>
<a name="l00315"></a><a class="code" href="portable__iarchive_8hpp.html#acc351baaf7169bfeb132ce3d02dbe7e1">00315</a> <span class="preprocessor"></span><span class="preprocessor">#define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES eos::portable_iarchive</span>
<a name="l00316"></a>00316 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00317"></a>00317 <span class="preprocessor"></span>BOOST_SERIALIZATION_REGISTER_ARCHIVE(<a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">eos::portable_iarchive</a>)
<a name="l00318"></a>00318 <span class="preprocessor">#endif</span>
<a name="l00319"></a>00319 <span class="preprocessor"></span>
<a name="l00320"></a><a class="code" href="namespaceboost_1_1archive.html">00320</a> <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>archive {
<a name="l00321"></a>00321 
<a name="l00322"></a>00322    <span class="comment">// explicitly instantiate for this type of binary stream</span>
<a name="l00323"></a>00323    <span class="keyword">template</span> <span class="keyword">class </span>basic_binary_iarchive&lt;eos::portable_iarchive&gt;;
<a name="l00324"></a>00324 
<a name="l00325"></a>00325    <span class="keyword">template</span> <span class="keyword">class </span>basic_binary_iprimitive&lt;
<a name="l00326"></a>00326       <a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">eos::portable_iarchive</a>
<a name="l00327"></a>00327 <span class="preprocessor">      #if BOOST_VERSION &lt; 103400</span>
<a name="l00328"></a>00328 <span class="preprocessor"></span>         , std::istream
<a name="l00329"></a>00329 <span class="preprocessor">      #else</span>
<a name="l00330"></a>00330 <span class="preprocessor"></span>         , std::istream::char_type 
<a name="l00331"></a>00331          , std::istream::traits_type
<a name="l00332"></a>00332 <span class="preprocessor">      #endif</span>
<a name="l00333"></a>00333 <span class="preprocessor"></span>   &gt;;
<a name="l00334"></a>00334 
<a name="l00335"></a>00335    <span class="keyword">template</span> <span class="keyword">class </span>binary_iarchive_impl&lt;
<a name="l00336"></a>00336       <a class="code" href="classeos_1_1portable__iarchive.html" title="Portable binary input archive using little endian format.">eos::portable_iarchive</a>
<a name="l00337"></a>00337 <span class="preprocessor">      #if BOOST_VERSION &gt;= 103400</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span>         , std::istream::char_type 
<a name="l00339"></a>00339          , std::istream::traits_type
<a name="l00340"></a>00340 <span class="preprocessor">      #endif</span>
<a name="l00341"></a>00341 <span class="preprocessor"></span>   &gt;;
<a name="l00342"></a>00342 
<a name="l00343"></a>00343 <span class="preprocessor">#if (! _QX_USE_EXPORT_DLL_BOOST_SERIALIZATION_SINGLETON)</span>
<a name="l00344"></a>00344 <span class="preprocessor"></span><span class="preprocessor">#if (BOOST_VERSION &gt; 103800)</span>
<a name="l00345"></a>00345 <span class="preprocessor"></span>   <span class="keyword">template</span> <span class="keyword">class </span>detail::archive_serializer_map&lt;eos::portable_iarchive&gt;;
<a name="l00346"></a>00346 <span class="preprocessor">#else</span>
<a name="l00347"></a>00347 <span class="preprocessor"></span>   <span class="keyword">template</span> <span class="keyword">class </span>detail::archive_pointer_iserializer&lt;eos::portable_iarchive&gt;;
<a name="l00348"></a>00348 <span class="preprocessor">#endif // (BOOST_VERSION &gt; 103800)</span>
<a name="l00349"></a>00349 <span class="preprocessor"></span><span class="preprocessor">#endif // (! _QX_USE_EXPORT_DLL_BOOST_SERIALIZATION_SINGLETON)</span>
<a name="l00350"></a>00350 <span class="preprocessor"></span>
<a name="l00351"></a>00351 } } <span class="comment">// namespace boost::archive</span>
<a name="l00352"></a>00352 
<a name="l00353"></a>00353 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(pop)</span>
<a name="l00355"></a>00355 <span class="preprocessor"></span><span class="preprocessor">#endif // _MSC_VER</span>
<a name="l00356"></a>00356 <span class="preprocessor"></span>
<a name="l00357"></a>00357 <span class="preprocessor">#endif // _QX_PORTABLE_BINARY_IARCHIVE_H_</span>
<a name="l00358"></a>00358 <span class="preprocessor"></span><span class="preprocessor">#endif // _QX_SERIALIZE_PORTABLE_BINARY</span>
<a name="l00359"></a>00359 <span class="preprocessor"></span><span class="preprocessor">#endif // _QX_ENABLE_BOOST_SERIALIZATION</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="portable__iarchive_8hpp.html">portable_iarchive.hpp</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Sun Dec 11 2016 13:41:04 for QxOrm by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
